webpackJsonp([3],{

/***/ 0:
/***/ (function(module, exports, __webpack_require__) {

	var APP = __webpack_require__(1);
	var VALIDATE = __webpack_require__(17);
	var UTIL = __webpack_require__(18);
	var POWER = __webpack_require__(19);
	var page = {
	    subject: null,
	    activeIndex: 0,
	    footerHeight: null,
	    ruid: 888,
	    agoraRtc: null,
		uid:null,
		code:null,
	    ready: function() {
	        var that = this;
			that.uid = api.pageParam.uid;
			that.code = api.pageParam.code;
	        that.agoraRtc = api.require('agoraRtc');
	        // 头部处理
	        var headerHeight = $('#header').height();
	        $('body').css('padding-top', headerHeight);
			// POWER.opWithPermission('camera');//相机权限
			// POWER.opWithPermission('microphone');//打开麦克风
			that.initFrame();
	    },
	    on: function() {
	        var that = this;
			// 禁止屏幕休眠
			api.setKeepScreenOn({
			    keepOn: true
			});
			//点击返回
			API.listenEvt('keyback', function() {
				console.log('返回')
				API.sendEvt('CLOSE_AGORARTC',{});
				api.setKeepScreenOn({
				    keepOn: false
				});
			});
	        //批量事件start
	        var events = [
	            //打开页面
	            ['#add-channel', function() {
	                
	            }],
	            // 关闭页面
	            ['#close', function() {
	                
	            }],
	        ];
	        APP.e.more(events);
	        //批量事件end
	    },
	    methods: {
	        initFrame: function() {
				var that = this;
				api.openFrame({
				    name: 'main',
				    url: './main.html',
				    rect: {
				        x: 0,
				        y: 0,
				        w: 'auto',
				        h: 'auto'
				    },
				    pageParam: {
						uid : that.uid,
						code : that.code,
				    }
				});
	        }
	    }
	}
	API.run(page);


/***/ }),

/***/ 17:
/***/ (function(module, exports) {

	module.exports = {
		//检查手机
		checkPhone : function(val) {
			var pattern = /^1[3456789]\d{9}$/;
			return pattern.test(val);
		},
		//检查身份证
		checkIdCardNo : function(val) {
			var pattern = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
			return pattern.test(val);
		},
		//检查密码
		// checkPassword : function(val) {
		// 	var len = val.length;
		// 	if (len > 20 || len < 6) {
		// 		return false;
		// 	}
		// 	return true;
		// },
		//检查密码
		checkPassword : function(val) {
			var pattern = /^\w{6,16}$/;
			return pattern.test(val);
		},
		//邀请码
		checkCode : function(val) {
			var len = val.length;
			if (len != 6) {
				return false;
			}
			return true;
		},
		checkAreaId : function(val) {
			var len = val.length;
			if (len != 6) {
				return false;
			}
			return true;
		},
		// 检查姓名
		checkName : function(val) {
			var pattern = /^[0-9A-Za-z_|\u4e00-\u9fa5]{1,}$/;
			return pattern.test(val);
		},
	}


/***/ }),

/***/ 18:
/***/ (function(module, exports) {

	module.exports = {
		countdown : 60,
		//发送验证码倒计时
		settime : function(obj) {
			var that = this;
			if (that.countdown == 0) {
				obj.setAttribute("rel", 'send');
				obj.innerHTML = "重新发送";
				obj.className += ' codeBtn';
				that.countdown = 60;
				return;
			} else {
				obj.removeAttribute("rel");
				obj.innerHTML = "重新发送(" + that.countdown + 's' + ")";
				that.countdown--;
			}
			setTimeout(function() {
				that.settime(obj)
			}, 1000)
		},
		//秒杀倒计时
		countTime : function(_date, callback) {
			var that = this;
			//获取当前时间
			var date = new Date();
			var now = date.getTime();
			//设置截止时间
			_date = _date.replace(/-/g, '/'); 
			var endDate = new Date(_date);
			var end = endDate.getTime();
			//时间差
			var leftTime = end - now;
			//定义变量 d,h,m,s保存倒计时的时间
			var d, h, m, s;
			if (leftTime >= 0) {
				d = Math.floor(leftTime / 1000 / 60 / 60 / 24);
				h = Math.floor(leftTime / 1000 / 60 / 60 % 24);
				m = Math.floor(leftTime / 1000 / 60 % 60);
				s = Math.floor(leftTime / 1000 % 60);
				
				h = (h+"").length == 1 ? '0'+h : h;
				m = (m+"").length == 1 ? '0'+m : m;
				s = (s+"").length == 1 ? '0'+s : s;
				//将倒计时赋值到div中
				//obj.find('[rel="_d"]').html(d);
				//obj.find('[rel="_h"]').html(h);
				//obj.find('[rel="_m"]').html(m);
				//obj.find('[rel="_s"]').html(s);
				
				if(d>0) {
					document.getElementById("t_day").innerHTML = d+'日';
				}
				document.getElementById("t_hour").innerHTML = h;
				document.getElementById("t_minute").innerHTML = m;
				document.getElementById("t_second").innerHTML = s;

				//递归每秒调用countTime方法，显示动态时间效果
				setTimeout(function() {
					that.countTime(_date, callback);
				}, 1000);
			} else {
				$.isFunction(callback) && callback();
			}
		},
		countTimeMuti : function(_obj, callback) {
			var that = this;
			//获取当前时间
			var date = new Date();
			var now = date.getTime();
			//设置截止时间
			var _date = _obj.data('startdate');
			_date = _date.replace(/-/g, '/'); 
			var endDate = new Date(_date);
			var end = endDate.getTime();
			//时间差
			var leftTime = end - now;
			//定义变量 d,h,m,s保存倒计时的时间
			var d, h, m, s;
			if (leftTime >= 0) {
				d = Math.floor(leftTime / 1000 / 60 / 60 / 24);
				h = Math.floor(leftTime / 1000 / 60 / 60 % 24);
				m = Math.floor(leftTime / 1000 / 60 % 60);
				s = Math.floor(leftTime / 1000 % 60);
				
				h = (h+"").length == 1 ? '0'+h : h;
				m = (m+"").length == 1 ? '0'+m : m;
				s = (s+"").length == 1 ? '0'+s : s;
				//将倒计时赋值到div中
				
				_obj.find('.t_hour').text(h);
				_obj.find('.t_minute').text(m);
				_obj.find('.t_second').text(s);

				//递归每秒调用countTime方法，显示动态时间效果
				setTimeout(function() {
					that.countTimeMuti(_obj, callback);
				}, 1000);
			} else {
				$.isFunction(callback) && callback();
			}
		},
		//展示时间类型
		showMusicTimeText: function(duration) {
			if(duration<10) return '00:0'+duration.toFixed(0);
			var _m = Math.floor(duration/60).toFixed(0);
			if(_m < 10) _m = '0'+_m;
			var _s = Math.floor(duration%60).toFixed(0);
			if(_s < 10) _s = '0'+_m;
			return _m+':'+_s;
		}
	}

/***/ }),

/***/ 19:
/***/ (function(module, exports, __webpack_require__) {

	var APP = __webpack_require__(1)
	module.exports = {
		// <div id="wrap">
		// 	<div id='header'>
		//         <div class="back" tapmode="back-active" onclick="api.closeWin()" >返回</div>
		//         <h1>权限管理测试</h1>
		//         <div class="adpt" ></div>
		// 	</div>
		// 	<div class='itemtitle'>一、判断权限</div>
		// 	<div class='marg'>请选择一个或者多个权限进行判断:</div>
		// 	<div class='marg'>日历&emsp;&emsp;&emsp;<input type="checkbox" name="p_list" value="calendar" /></div>
		// 	<div class='marg'>相机&emsp;&emsp;&emsp;<input type="checkbox" name="p_list" value="camera" /></div>
		// 	<div class='marg'>通讯录&emsp;&emsp;<input type="checkbox" name="p_list" value="contacts" /></div>
		// 	<div class='marg'>位置信息&emsp;<input type="checkbox" name="p_list" value="location" /></div>
		// 	<div class='marg'>麦克风&emsp;&emsp;<input type="checkbox" name="p_list" value="microphone" /></div>
		// 	<div class='marg'>电话&emsp;&emsp;&emsp;<input type="checkbox" name="p_list" value="phone" /></div>
		// 	<div class='marg'>身体传感器<input type="checkbox" name="p_list" value="sensor" /></div>
		// 	<div class='marg'>短信&emsp;&emsp;&emsp;<input type="checkbox" name="p_list" value="sms" /></div>
		// 	<div class='marg'>存储空间&emsp;<input type="checkbox" name="p_list" value="storage" /></div>
		// 	<div class="clickbtn" tapmode="active" onclick="hasPermission()" >点击开始判断</div>
		// 	<div class='itemtitle'>二、请求权限</div>
		// 	<div class='marg'>请选择一个或者多个权限进行请求:</div>
		// 	<div class='marg'>日历&emsp;&emsp;&emsp;<input type="checkbox" name="p_list_r" value="calendar" /></div>
		// 	<div class='marg'>相机&emsp;&emsp;&emsp;<input type="checkbox" name="p_list_r" value="camera" /></div>
		// 	<div class='marg'>通讯录&emsp;&emsp;<input type="checkbox" name="p_list_r" value="contacts" /></div>
		// 	<div class='marg'>位置信息&emsp;<input type="checkbox" name="p_list_r" value="location" /></div>
		// 	<div class='marg'>麦克风&emsp;&emsp;<input type="checkbox" name="p_list_r" value="microphone" /></div>
		// 	<div class='marg'>电话&emsp;&emsp;&emsp;<input type="checkbox" name="p_list_r" value="phone" /></div>
		// 	<div class='marg'>身体传感器<input type="checkbox" name="p_list_r" value="sensor" /></div>
		// 	<div class='marg'>短信&emsp;&emsp;&emsp;<input type="checkbox" name="p_list_r" value="sms" /></div>
		// 	<div class='marg'>存储空间&emsp;<input type="checkbox" name="p_list_r" value="storage" /></div>
		// 	<div class="clickbtn" tapmode="active" onclick="reqPermission()" >点击开始请求</div>
		// 	<div class='itemtitle'>三、需要权限的API操作</div>
		// 	<div class='marg'>1、日历</div>
		// 	<div class="clickbtn" tapmode="active" onclick="opWithPermission('calendar')" >点击操作日历</div>
		// 	<div class='marg'>2、相机</div>
		// 	<div class="clickbtn" tapmode="active" onclick="opWithPermission('camera')" >点击操作照相机</div>
		// 	<div class='marg'>3、通讯录</div>
		// 	<div class="clickbtn" tapmode="active" onclick="opWithPermission('contacts')" >点击操作通讯录</div>
		// 	<div class='marg'>4、位置信息</div>
		// 	<div class="clickbtn" tapmode="active" onclick="opWithPermission('location')" >点击操作位置信息</div>
		// 	<div class='marg'>5、麦克风</div>
		// 	<div class="clickbtn" tapmode="active" onclick="opWithPermission('microphone')" >点击操作麦克风</div>
		// 	<div class='marg'>6、电话</div>
		// 	<div class="clickbtn" tapmode="active" onclick="opWithPermission('phone')" >点击操作电话</div>
		// 	<div class='marg'>7、身体传感器</div>
		// 	<div class="clickbtn" tapmode="active" onclick="opWithPermission('sensor')" >点击操作身体传感器</div>
		// 	<div class='marg'>8、短信</div>
		// 	<div class="clickbtn" tapmode="active" onclick="opWithPermission('sms')" >点击操作短信</div>
		// 	<div class='marg'>9、存储空间</div>
		// 	<div class="clickbtn" tapmode="active" onclick="opWithPermission('storage')" >点击操作存储空间</div>
		//     <br>
		// </div>
		//初始化
		init: function() {
			var that = this;
			var powerHtml = '<div class="powerBox hidden">' +
				'<div class="marg hidden">日历&emsp;&emsp;&emsp;<input type="checkbox" name="p_list_r" value="calendar" /></div>' +
				'<div class="marg hidden">相机&emsp;&emsp;&emsp;<input type="checkbox"  name="p_list_r" value="camera" /></div>' +
				'<div class="marg hidden">通讯录&emsp;&emsp;<input type="checkbox"  name="p_list_r" value="contacts" /></div>' +
				'<div class="marg hidden">位置信息&emsp;<input type="checkbox"   name="p_list_r" value="location" /></div>' +
				'<div class="marg hidden">麦克风&emsp;&emsp;<input type="checkbox"  name="p_list_r" value="microphone" /></div>' +
				'<div class="marg hidden">身体传感器<input type="checkbox" name="p_list_r" value="sensor" /></div>' +
				'<div class="marg hidden">短信&emsp;&emsp;&emsp;<input type="checkbox" name="p_list_r" value="sms" /></div>' +
				'<div class="marg hidden">存储空间&emsp;<input type="checkbox" checked="checked" name="p_list_r" value="storage" /></div>' +
				'<div class="marg hidden">电话&emsp;&emsp;&emsp;<input type="checkbox" name="p_list_r" value="phone" /></div>' +
				'<div class="clickbtn hidden" tapmode="active" onclick="reqPermission()" >' + '点击开始请求</div>' +
				'<div class="clickbtn hidden">通知&emsp;&emsp;&emsp;<input type="checkbox" checked="checked" name="p_list_r" value="notification" /></div>' +
				'</div>'
			return powerHtml;
		},
		//验证权限
		hasPermission: function(one_per,callback) {
			var that = this;
			// 验证
			var perms = new Array();
			if (one_per) {
				perms.push(one_per);
			} else {
				var prs = document.getElementsByName("p_list_r");
				for (var i = 0; i < prs.length; i++) {
					if (prs[i].checked) {
						perms.push(prs[i].value);
					}
				}
			}
			var rets = api.hasPermission({
				list: perms
			});
			var _num = 0;
			var _granted = 0;
			var _txt = 'Whetstone驾培需要获取';
			for (var i in rets) {
				if (!rets[i].granted) {
					_granted = _num = _num + 1;
				}
			}
			for (var i in rets) {
				if (!rets[i].granted) {
					switch (rets[i].name) {
						case 'calendar':
							_txt += '日历读写'
							break;
						case 'camera':
							_txt += '相机'
							break;
						case 'contacts':
							_txt += '通讯录'
							break;
						case 'location':
							_txt += '位置信息'
							break;
						case 'microphone':
							_txt += '麦克风'
							break;
						case 'phone':
							_txt += '直接拨打电话'
							break;
						case 'sensor':
							_txt += '身体传感器'
							break;
						case 'sms':
							_txt += '发送短信'
							break;
						case 'storage':
							_txt += '存储空间'
							break;
						case 'notification':
							_txt += '状态栏通知'
							break;
						default:
							break;
					}
					_num = _num - 1;
					if (_num > 0) {
						_txt += '、'
					}
				}
			}
			_txt += '权限才能正常使用功能';
			if (_granted > 0) {
				if (!one_per) {
					that.reqPermission(one_per,callback);
				} else {
					that.reqPermission(one_per,callback);
				}
				// api.alert({
				// 	msg:_txt
				// }, function(ret, err) {
				// 	if (!one_per) {
				// 		that.reqPermission();
				// 	} else{
				// 		that.reqPermission(one_per);
				// 	}
				// });
			}else{
				//已获得权限
				$.isFunction(callback) && callback(rets);
			}
			if (!one_per) {
				// $.isFunction(callback) && callback(rets);
				// console.log('判断结果：' + JSON.stringify(rets));
				return;
			}
			
			
			return rets;
		},

		// 获取权限
		reqPermission: function(one_per, callback) {
			var that = this;
			var perms = new Array();

			if (one_per) {
				perms.push(one_per);
			} else {
				var prs = document.getElementsByName("p_list_r");
				for (var i = 0; i < prs.length; i++) {
					if (prs[i].checked) {
						perms.push(prs[i].value);
					}
				}
			}
			api.requestPermission({
				list: perms,
				code: 100001
			}, function(ret, err) {
				
				if (callback) {
					$.isFunction(callback) && callback(ret);
					return;
				}

				// that.hasPermission();
				// api.confirm({
				// 	title: 'testtitle',
				// 	msg: 'testmsg',
				// 	buttons: ['确定', '取消']
				// }, function(ret, err) {
				// 	var index = ret.buttonIndex;
				// });
				// api.alert({
				// 	msg:JSON.stringify(ret)
				// });
				// var str = '请求结果：\n';
				// str += '请求码: ' + ret.code + '\n';
				// str += "是否勾选\"不再询问\"按钮: " + (ret.never ? '是' : '否') + '\n';
				// str += '请求结果: \n';
				// var list = ret.list;
				// for (var i in list) {
				// 	str += list[i].name + '=' + list[i].granted + '\n';
				// }
				// console.log('获取权限：'+JSON.stringify(ret));
				// console.log(JSON.stringify(ret));
			});
		},
		// 获取单个权限
		opWithPermission: function(perm) {
			var that = this;
			that.hasPermission(perm);
			// if (!that.confirmPer(perm)) {
			// 	return;
			// }
			if ('calendar' == perm) {
				//操作日历
			} else if ('camera' == perm) {
				// api.getPicture({
				// 	sourceType: 'camera',
				// 	mediaValue: 'pic',
				// 	destinationType: 'url',
				// }, function(ret, err) {
				// 	if (callback) {
				// 		callback(ret);
				// 		return;
				// 	}
				// 	if (ret) {
				// 		console.log(JSON.stringify(ret));
				// 	} else {
				// 		console.log(JSON.stringify(err));
				// 	}
				// });
			} else if ('contacts' == perm) {
				api.openContacts({
					test: true
				}, function(ret, err) {
					if (ret && ret.status) {
						// console.log(JSON.stringify(ret));
					} else {
						// console.log(JSON.stringify(err));
					}
				});
			} else if ('location' == perm) {
				api.getLocation(function(ret, err) {
					if (ret && ret.status) {
						// console.log(JSON.stringify(ret));
					} else {
						// console.log(JSON.stringify(err));
					}
				});
			} else if ('microphone' == perm) {
				api.startRecord({
					path: 'fs://perm-test.amr'
				});
			} else if ('phone' == perm) {
				api.call({
					type: 'tel',
					number: '10086'
				});
			} else if ('sensor' == perm) {
				//操作身体传感器
			} else if ('sms' == perm) {
				api.sms({
					numbers: ['10086'],
					text: '余额',
					silent: true
				});
			} else if ('storage' == perm) {
				api.readFile({
					path: 'fs://test.txt'
				}, function(ret, err) {
					if (ret.status) {
						// console.log('readFile: ' + ret.data);
					} else {
						// console.log(err.msg + ": \n" + api.fsDir);
					}
				});
			}
		},

		confirmPer: function(perm) {
			var that = this;
			var has = that.hasPermission(perm);
			if (!has || !has[0] || !has[0].granted) {
				api.confirm({
					title: '提醒',
					msg: '没有获得 ' + perm + " 权限\n是否前往设置？",
					buttons: ['去设置', '取消']
				}, function(ret, err) {
					if (1 == ret.buttonIndex) {
						that.reqPermission(perm);
					}
				});
				return false;
			}
			return true;
		}

	}


/***/ })

});